﻿/*
 * Copyright (c) Martin Kinkelin
 *
 * See the "License.txt" file in the root directory for infos
 * about permitted and prohibited uses of this code.
 */

using System;
using System.Windows.Forms;

namespace Jarf
{
	/// <summary>
	/// Displays the result of a Rsync simulation process (a dry run) and
	/// asks the user for confirmation.
	/// </summary>
	public partial class SimulationResultDialog : BaseForm
	{
		/// <summary>
		/// Constructor.
		/// </summary>
		/// <param name="process">Successfully completed Rsync simulation process.</param>
		/// <param name="restoring">
		/// Indicates whether a the current operation is a restore or backup operation.
		/// </param>
		public SimulationResultDialog(RsyncProcess process, bool restoring)
		{
			if (process == null)
				throw new ArgumentNullException("process");

			InitializeComponent();

			label1.Text = string.Format(label1.Text,
				(restoring ? process.Task.Source : process.Task.Destination));

			numFilesTransferredLabel.Text = process.NumTransferredFiles.ToString();

			int numDeletions = process.NumDeletions;
			if (numDeletions > 0)
			{
				numDeletionsLabel.Text = numDeletions.ToString();
				numDeletionsLabel.ForeColor = System.Drawing.Color.Red;
			}

			outputTextBox.Text = process.FullOutput;
			outputTextBox.Select(0, 0);
		}
	}
}
